package com.sc.testservice.service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import androidx.annotation.Nullable;
import android.util.Log;

/**
 * Created by Shen Chao on 2018-01-22-022 下午 14:35.
 */

public class MyService extends Service {
    public static final String TAG = "MyService";

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.i(TAG, "服务被绑定");
        return new MyBinder();
    }

    public class MyBinder extends Binder implements IService {
        @Override
        public void callChange(String s) {
            change(s);
        }
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.i(TAG, "服务被解绑");
        return super.onUnbind(intent);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i(TAG, "服务创建");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "服务销毁");
    }

    public void change(String str) {
        Log.i(TAG, "改变了：" + str);
    }
}
